/*
by txdnet.cn tonydon
 */

package txdnet.db;

import java.sql.*;
import org.logicalcobwebs.proxool.configuration.*;
import txdnet.util.*;
/**
 *
 * @author txdnet
 */
public class ProxoolPool {
 private static ProxoolPool proxoolPool = init();

    private ProxoolPool(){}

public static Connection getConnection(){
    return ProxoolPool.getConnection("proxool.db-1");
}

public static Connection getConnection(String dbflag){
            Connection conn = null;
   try {
            conn = DriverManager.getConnection(dbflag);
       }catch (Exception e){
            Logger.error(ProxoolPool.class, e.toString());
            conn=null;
            }
            return conn ;
}

private static ProxoolPool init(){
       try{
        Class.forName("org.logicalcobwebs.proxool.ProxoolDriver");
        PropertyConfigurator.configure(PoolFactory.getDbProperties());
        proxoolPool = (ProxoolPool)Class.forName("txdnet.db.ProxoolPool").newInstance();
        }catch(Exception e){
            Logger.error(ProxoolPool.class, e.toString());
            proxoolPool = null;
        }
         return proxoolPool;
    }
}